import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '@/store';

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch((err) => err)
}
Vue.use(VueRouter)

const router = new VueRouter({
    mode: 'hash',
    routes: [{
        path: '/',
        component: () =>
            import ('@/views/musicHome'),
    }, {
        path: '/',
        component: () =>
            import ('@/views/musicHome.vue'),
        children: [{
            path: '/pageOne',
            component: () =>
                import ('@/views/homePageIndex.vue'),
            children: [{
                path: '/pageOne/recommend',
                component: () =>
                    import ('@/views/recommend.vue'),
                meta: {
                    keepAlive: true,
                },

            }, {
                path: '/pageOne/customized',
                component: () =>
                    import ('@/views/customized.vue'),
                meta: {
                    keepAlive: true,
                },
            }, {
                path: '/pageOne/Rank',
                component: () =>
                    import ('@/views/Rank.vue'),
                meta: {
                    keepAlive: true,
                },
            }, {
                path: '/pageOne/Artists',
                component: () =>
                    import ('@/views/artists.vue'),
                meta: {
                    keepAlive: true,
                },
            }],
        }, {
            path: '/songList',
            component: () =>
                import ('@/views/songList.vue'),
            meta: {
                keepAlive: false,
            },
        }, {
            path: '/seachPage',
            component: () =>
                import ('@/views/seachPage.vue'),
            meta: {
                keepAlive: false,
            },
        }, {
            path: '/artistsPage',
            component: () =>
                import ('@/views/artistsPage.vue'),
            meta: {
                keepAlive: false,
            },
        }, {
            path: '/albumPage',
            component: () =>
                import ('@/views/albumPage.vue'),
            meta: {
                keepAlive: false,
            },
        }, {
            path: '/mvPlay',
            component: () =>
                import ('@/views/mvPage.vue'),
            meta: {
                keepAlive: false,
            },
        }, {
            path: '/pageTwo',
            component: () =>
                import ('@/views/MVpage/mvPageIndex.vue'),
            children: [{
                path: '/pageTwo/videoRec',
                component: () =>
                    import ('@/views/MVpage/videoRec.vue'),
                meta: {
                    keepAlive: true,
                },
            }, {
                path: '/pageTwo/mvRec',
                component: () =>
                    import ('@/views/MVpage/mvRec.vue'),
                meta: {
                    keepAlive: true,
                },
            }],
        }, {
            path: '/videoPage',
            component: () =>
                import ('@/views/MVpage/videoPage/videoPage.vue'),
            meta: {
                keepAlive: false,
            },
        }, {
            path: '/allMv',
            component: () =>
                import ('@/views/MVpage/allMv.vue'),
            meta: {
                keepAlive: false,
            },
        }, {
            path: '/rankPage',
            component: () =>
                import ('@/views/MVpage/rankPage.vue'),
            meta: {
                keepAlive: true,
            },
        }, {
            path: '/songCom',
            component: () =>
                import ('@/components/songComment.vue'),
        }, {
            path: '/LikePage',
            component: () =>
                import ('@/views/likePage.vue'),
        }, {
            path: '/userPage',
            component: () =>
                import ('@/views/userPage.vue'),
        }, {
            path: '/recentSong',
            component: () =>
                import ('@/views/recentSong.vue')
        }],
    }],
})

// router.beforeEach((to, from, next) => {
//     store.commit('CLAER_CANCEL'); // 取消请求
//     next()
// })
export default router